﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using Microsoft.Phone.Controls;

namespace PhoneToolkit.Extensions.Behaviors
{
    public class TransitionSwivelOutBehavior : Behavior<PhoneApplicationPage>
    {
        protected override void OnAttached()
        {
            base.OnAttached();

            NavigationOutTransition navOutTrans = new NavigationOutTransition();
            navOutTrans.Backward = new SwivelTransition() { Mode = TransitionModeBackwardOut };
            navOutTrans.Forward = new SwivelTransition() { Mode = TransitionModeForwardOut };
            TransitionService.SetNavigationOutTransition(this.AssociatedObject, navOutTrans);
        }

        protected override void OnDetaching()
        {
            base.OnDetaching();
        }

        public static readonly DependencyProperty TransitionModeBackwardOutProperty = DependencyProperty.Register("TransitionModeSwivelBackWardOut", typeof(SwivelTransitionMode), typeof(TransitionSwivelOutBehavior), new PropertyMetadata(SwivelTransitionMode.BackwardOut));
        public static readonly DependencyProperty TransitionModeForwardOutProperty = DependencyProperty.Register("TransitionModeSwivelForwardOut", typeof(SwivelTransitionMode), typeof(TransitionSwivelOutBehavior), new PropertyMetadata(SwivelTransitionMode.ForwardOut));

        public SwivelTransitionMode TransitionModeBackwardOut
        {
            get { return (SwivelTransitionMode)GetValue(TransitionModeBackwardOutProperty); }
            set { SetValue(TransitionModeBackwardOutProperty, value); }
        }

        public SwivelTransitionMode TransitionModeForwardOut
        {
            get { return (SwivelTransitionMode)GetValue(TransitionModeForwardOutProperty); }
            set { SetValue(TransitionModeForwardOutProperty, value); }
        }
    }
}
